<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>科研动态</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="../../common/css/iconfont0.css">
		<link rel="stylesheet" href="../../common/mui/mui.min.css">
		<link rel="stylesheet" href="../../common/css/publicStyle.css">
		<link rel="stylesheet" href="fileListP.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="box-shadow:  0px 0px 0px #000000;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<a class="search iconfont icon-sousuo mui-pull-right" style="color: white;display: none;" onclick="searchPDF()"></a>
			<div id="navimg"><img src="../../common/images/logo-white.png" width="130px" height="20px"></div>
	
		</header>
		<div class="mui-content">
			<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
				<div id="tab" class="mui-scroll"></div>
			</div>
		</div>
		<script src="../../common/mui/mui.min.js"></script>
		<script src="../../common/js/h5adapter.js"></script>
		<script src="../../common/js/webviewGroup.js" type="text/javascript" charset="utf-8"></script>
		<script>
			var pagesArr
			mui.init();
			mui.plusReady(function() {
				try {
					var deceleration = mui.os.ios ? 0.003 : 0.0009;
					mui('.mui-scroll-wrapper').scroll({
						bounce: false,
						indicators: false, //是否显示滚动条
						deceleration: deceleration
					});
					var _self = plus.webview.currentWebview();
					_self.setStyle({
						popGesture: 'none'  // 作用于ios 禁止右滑关闭
					});
					pagesArr = _self.getExtras().subPage
					if (_self.getExtras().from == 'tab-home.html') {
						mui('.mui-bar .search')[0].style.display = 'block'
					}
					var html = '',width = 25,lastWidth = 25
					width = (100/pagesArr.length).toFixed(2)
					lastWidth = 100 - width*(pagesArr.length-1)
					for (var i = 0; i < pagesArr.length; i++) {
						var onePage = pagesArr[i] //{id: url,url: url,extras: {}}
						var active=''
						if (i == 0) {
							active = 'mui-active'
						}
						var style='style="width:'+width+'%"'
						if (i == pagesArr.length-1) {
							style='style="width:'+lastWidth+'%"'
						}
						html += '<div id="'+i+'-item" '+style+' class="mui-control-item '+active+'" data-wid="'+onePage['id']+'">'+onePage['title']+'</div>'
					}
					mui('#tab')[0].innerHTML = html;
					mui('.mui-slider').slider();
					var group = new webviewGroup(_self.id, {
						items: pagesArr,
						onChange: function(obj) {
							var c = document.querySelector(".mui-control-item.mui-active");
							if(c) {
								c.classList.remove("mui-active");
							}
							var target = document.querySelector(".mui-scroll .mui-control-item:nth-child(" + (parseInt(obj.index) + 1) + ")");
							target.classList.add("mui-active");
							if(target.scrollIntoView) {
								target.scrollIntoView();
							}
						}
					});
					mui(".mui-scroll").on("tap", ".mui-control-item", function(e) {
						var wid = this.getAttribute("data-wid");
						group.switchTab(wid);
					});
					
				} catch (error) {
					mui.toast(error)
					//TODO handle the exception
				}
				if (_self.from == undefined) {
					mui.back = function() {
						var _self = plus.webview.currentWebview();
						_self.close("auto");
					}
				}
			});
			

			function searchPDF() {
				var index = parseInt(mui('#tab .mui-active')[0].id)
				var category = pagesArr[index]['extras']['category']
				var pid = pagesArr[index]['extras']['pid']
				var extras = {'category':category}
				if (pid) {
					extras.pid = pid
				}
				//console.log(category);
				mui.openWindow({
					url: 'pdf-search.html',
					id: 'pdf-search.html',
					extras: extras,
					waiting: {
						autoShow: false, //自动显示等待框，默认为true
					}
				});
			}
		</script>
	</body>

</html>